package com.sino.struts2;

import java.util.Calendar;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.sino.business.IBasicInfoService;
import com.sino.business.IPatentManageService;
import com.sino.business.IStaticDataService;
import com.sino.model.BasicInfoModel;
import com.sino.model.TjyjModel;
import com.sino.second.business.IReviewService;
import com.sino.second.business.service.Review1ServiceImpl;
import com.sino.second.exception.BusinessException;
import com.sino.util.SysParameter;
import com.googlecode.jsonplugin.annotations.SMDMethod;

public class ZlmanageAction extends ActionSupport {

	private String zlid;// 专利编号
	private IStaticDataService staticDateService;// 基础数据

	private IBasicInfoService basicInfoService;// 基本信息

	private IPatentManageService patentManageService;// 专利管理

	private TjyjModel tjyjModel;

	private BasicInfoModel basicinfoModel;
	
	private String shbz[];

	private String qxkz = "0000";

	private List hyList;

	private List xkList;

	private List zlTypeList;

	private List zlType1List;

	private List xkzlList;

	private List areaList;

	private List flztList;

	private List qxkwList;
	private String selectLianDong;

	public String getSelectLianDong() {
		return selectLianDong;
	}

	public void setSelectLianDong(String selectLianDong) {
		this.selectLianDong = selectLianDong;
	}

	public List getAreaList() {
		return areaList;
	}

	public void setAreaList(List areaList) {
		this.areaList = areaList;
	}

	public List getFlztList() {
		return flztList;
	}

	public void setFlztList(List flztList) {
		this.flztList = flztList;
	}

	public List getHyList() {
		return hyList;
	}

	public void setHyList(List hyList) {
		this.hyList = hyList;
	}

	public List getQxkwList() {
		return qxkwList;
	}

	public void setQxkwList(List qxkwList) {
		this.qxkwList = qxkwList;
	}

	public List getXkList() {
		return xkList;
	}

	public void setXkList(List xkList) {
		this.xkList = xkList;
	}

	public List getXkzlList() {
		return xkzlList;
	}

	public void setXkzlList(List xkzlList) {
		this.xkzlList = xkzlList;
	}

	public List getZlType1List() {
		return zlType1List;
	}

	public void setZlType1List(List zlType1List) {
		this.zlType1List = zlType1List;
	}

	public List getZlTypeList() {
		return zlTypeList;
	}

	public void setZlTypeList(List zlTypeList) {
		this.zlTypeList = zlTypeList;
	}

	public String viewZl() {

		this.setZlid(zlid);

		return SUCCESS;
	}

	@SMDMethod
	public BasicInfoModel doChangeZxbz(BasicInfoModel basicinfoModel) {

		if (basicinfoModel.getZxbz().equals("1")) {
			basicinfoModel.setZxbz("0");

		} else {

			basicinfoModel.setZxbz("1");
		}

		this.getBasicInfoService().updateZxbz(basicinfoModel);

		return basicinfoModel;
	}

	public String updateBasicInfo() {
		BasicInfoModel bi=new BasicInfoModel();
		bi.setZlid(zlid);
		if(!SysParameter.CURRENT_YEAR.toString().equals(new Integer(Calendar.getInstance().get(Calendar.YEAR)).toString())){
			throw new BusinessException("sys.notcheck.exception");
			
		}
		this.getBasicInfoService().updateBasicInfo(bi);

		return Action.SUCCESS;
	}
//	 --------根据zlid查找基本信息
	public String findBasicInfo() {
//		String hqlWhere = " tx1.year='" + SysParameter.CURRENT_YEAR + "'";// 获得系统年度
//		if(this.review1ServiceImpl.findCountReviewXmFsList(hqlWhere)>0)
//		{
//			throw new BusinessException("系统已经进行评分，不能再审核项目！");
//		}
		this.setHyList(this.getStaticDateService().findHyList());
		this.setXkList(this.getStaticDateService().findXkList());
		this.setZlTypeList(this.getStaticDateService().findZlTypeList());
		this.setZlType1List(this.getStaticDateService().findZlType1List());
		this.setXkzlList(this.getStaticDateService().findXkzlList());
		this.setAreaList(this.getStaticDateService().findAreaList());
		this.setFlztList(this.getStaticDateService().findFlztList());
		this.setQxkwList(this.getStaticDateService().findQxkwList());
		this.setSelectLianDong(this.getStaticDateService()
				.findZlTypeListSelect());

		HttpSession session = ServletActionContext.getRequest().getSession();
		this.setBasicinfoModel(this.getBasicInfoService().findBasicinfoById(
				zlid));

		return this.SUCCESS;
	}

	public String modifyShbz() {
		HttpServletRequest request = ServletActionContext.getRequest();
		String flag = request.getParameter("flag");

		this.getPatentManageService().updateBasicInfoShbz(flag, shbz);
		return SUCCESS;
	}

	public String viewTjyj() {
		tjyjModel = this.getPatentManageService().getTjyjByZlid(this.getZlid());

		this.setZlid(this.getZlid());

		return SUCCESS;
	}

	public String viewTjyjRpt() {

		tjyjModel = this.getPatentManageService().getTjyjRptByZlid(zlid);
		this.setTjyjModel(tjyjModel);

		return SUCCESS;
	}

	public String saveTjyj() {

		this.getPatentManageService().saveTjyj(tjyjModel);
		return SUCCESS;
	}

	public String getZlid() {
		return zlid;
	}

	public void setZlid(String zlid) {
		this.zlid = zlid;
	}

	public IBasicInfoService getBasicInfoService() {
		return basicInfoService;
	}

	public TjyjModel getTjyjModel() {
		return tjyjModel;
	}

	public void setTjyjModel(TjyjModel tjyjModel) {
		this.tjyjModel = tjyjModel;
	}

	public void setBasicInfoService(IBasicInfoService basicInfoService) {
		this.basicInfoService = basicInfoService;
	}

	public IPatentManageService getPatentManageService() {
		return patentManageService;
	}

	public void setPatentManageService(IPatentManageService patentManageService) {
		this.patentManageService = patentManageService;
	}

	public BasicInfoModel getBasicinfoModel() {
		return basicinfoModel;
	}

	public void setBasicinfoModel(BasicInfoModel basicinfoModel) {
		this.basicinfoModel = basicinfoModel;
	}

	public String[] getShbz() {
		return shbz;
	}

	public void setShbz(String[] shbz) {
		this.shbz = shbz;
	}

	public String getQxkz() {
		return qxkz;
	}

	public void setQxkz(String qxkz) {
		this.qxkz = qxkz;
	}

	public IStaticDataService getStaticDateService() {
		return staticDateService;
	}

	public void setStaticDateService(IStaticDataService staticDateService) {
		this.staticDateService = staticDateService;
	}

	
	
}
